<?php

namespace App\Http\Controllers\Baidu;

use Illuminate\Http\Request;
use	Exception;

include_once ('../app/libary/Baidu/sms_service_KeywordService.php');

use sms_service_KeywordService;
use GetWordRequest;
use App\Http\Controllers\Baidu\AdgroupController;

class KeyWordController
{

    var $keyword;
    var $getwordrequest;
    var $campain;

    public function __construct()
    {
        $this->keyword = new sms_service_KeywordService();
        $this->getwordrequest = new GetWordRequest();
        $this->adgroup = new  AdgroupController();
    }


    public function getKeyWord()
    {

        $wordFields = ['keywordId','campaignId','adgroupId','keyword','price','pause','matchType','phraseType','status',
            'wmatchprefer','pcDestinationUrl','pcQuality','pcScale','mobileDestinationUrl','mobileQuality','mobileScale',
            'tabs','leftPriceGuide','left3PriceGuide','mPriceGuide','pcQualityFactor','mobileQualityFactor'];
        $idType = 5;

        $ids = [];
//        $ids = [2618141435,2602965557];
        $ids = [2602964561];  //   每次查询单元ID只能为一个   需要传进来
//
//        $data  = $this->adgroup->getAdgroupData();
//        $data = json_decode($data);
//
//        foreach ($data->body as $key=> $item)
//        {
//           foreach ( $item as $value)
//           {
//               $ids[] .= $value->adgroupId;
//           }
//        }

//        dd($ids);



        $this->getwordrequest->setWordFields($wordFields);
        $this->getwordrequest->setIdType($idType);
        $this->getwordrequest->addId($ids);

        $result = $this->keyword->getWord($this->getwordrequest);
        return json_encode($result);

    }
    
    


}